<template>
	<view>
		<view class="">
			<cartTitle text="店铺信息"></cartTitle>
		</view>
		<view class="content" >
			<view class="">
				<selfCode @inputChang="taobaodianId" lable="淘宝店铺ID" inputName="taobao" :inputValue="user.taobaodianId" type="input" placeholder="请填写" :qianjin="false" dongLabelFontColor="#191919" dongLabelpaddingRight="36rpx"></selfCode>
			</view>
			<view class="">
				<selfCode @inputChang="jingdongdianId" lable="京东店铺ID" inputName="jindong" :inputValue="user.jingdongdianId" type="input" placeholder="请填写" :qianjin="false" dongLabelFontColor="#191919" dongLabelpaddingRight="36rpx"></selfCode>
			</view>
			<view class="">
				<selfCode @inputChang="pinduoduoId" lable="拼多多店铺ID" inpurtName="pinduoduo" :inputValue="user.pinduoduoId" type="input" placeholder="请填写" borderBottom="unset" :qianjin="false" dongLabelFontColor="#191919" dongLabelpaddingRight="36rpx"></selfCode>
			</view>
			<view class="">
				<selfCode @inputChang="alibabadianId" lable="阿里巴巴ID" inpurtName="alibaba" :inputValue="user.alibabadianId" type="input" placeholder="请填写" borderBottom="unset" :qianjin="false" dongLabelFontColor="#191919" dongLabelpaddingRight="36rpx"></selfCode>
			</view>
		</view>
		<view class="" style="padding:0 54rpx 80rpx;">
			<submitButtom text="保存" :buttonMethod="submit"></submitButtom>
		</view>
		<selfPopupMessage ref="selfPopupMessage"></selfPopupMessage>
	</view>
</template>

<script>
	import cartTitle from '@/components/self-cart-title/self-cart-title.vue'
	import selfCode from "@/components/self-card/self-card.vue" 
	import submitButtom from "@/components/submit-button/submit-button.vue"
	export default {
		components:{
			cartTitle,
			selfCode,
			submitButtom
		},
		data() {
			return {
				user:{
					taobaodianId:"",
					jingdongdianId:"",
					pinduoduoId:"",
					alibabadianId:""
				}
			}
		},
		
		onLoad() {
			var user = uni.getStorageSync("userInfo");
			this.user = user;
		},
		methods: {
			submit:function(){
				console.log(JSON.stringify(this.user));
				var that = this;
				
				this.$util.nuiAjax(this.$jiekou.updateUser,this.user,function(res){
					if(res.result=="true"){
						that.$refs.selfPopupMessage.open("保存成功");
						uni.$emit("update_user");
						if(that.user.taobaodianId !="" && that.user.jingdongdianId!="" && that.user.pinduoduoId!=""){
							uni.$emit("dianopuxinxi",{wanshan:true});
						}else{
							uni.$emit("dianopuxinxi",{wanshan:false});
						}
					}else{
						that.$refs.selfPopupMessage.open(res.message);
					}
				})	
			},
			pinduoduoId:function(value){
				this.user.pinduoduoId=value;
			},
			jingdongdianId:function(value){
				this.user.jingdongdianId=value;
			},
			taobaodianId:function(value){
				this.user.taobaodianId=value;
			},
			alibabadianId:function(value){
				this.user.alibabadianId=value;
			},
		}
	}
</script>
	
<style lang="scss">
	page{
		background-color: $page-bg-color;
	}
	.content{
		box-shadow:0px 8px 16px 0px rgba(246,247,248,1);
		background-color: #FFFFFF;
		margin-bottom: 80rpx;
	}
</style>
